﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AppPort;
using TI_EntityLib.TiEntityObjects.AttachInfo;
using TI;

namespace Controllers.AdministrationControllerCommands
{
    public class UpdateStateDocumentMetaItem
    {
        public class inUpdateDocumentMetaItem : DocumentMetaItem
        {
            public string DocID { get; set; }

            public int Part { get; set; }

            public bool FirstStepIsOK { get; set; }

            public bool SecondStepIsOK { get; set; }

            public override string ToString()
            {
                return Helper.Json<inUpdateDocumentMetaItem>.NewtonSerializeObject(this);
            }
        }      


        public static string Run(ServiceCmd cmd)
        {
            inUpdateDocumentMetaItem inP = Helper.Json<inUpdateDocumentMetaItem>.NewtonDeserializeObject(cmd.args.ToString());
             string script = "UpdateDocumentState('" + inP.DocID + "'," + inP.Part + "," + inP.FirstStepIsOK.ToString().ToLower() + "," + inP.SecondStepIsOK.ToString().ToLower() + ")";
            Helper.MongoTools.Instance.ExecuteScript(script);
            return "";
        }
    }
}
